AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( "shared.lua" )
 

ENT.Model = Model("models/props_c17/furnitureStove001a.mdl")

function ENT:Initialize()
	//self.Pos = self:GetPos()
	self.OldPos = Vector()
	self.speed = 10
	MsgN("models/weapons/w_rocket_launcher.mdl")
	self:SetModel( self.Model )
	//self:PhysicsInitSphere( 7 )
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_VPHYSICS )
	self:SetSolid( SOLID_VPHYSICS )	
end

function ENT:SetTarget( ent )
	self.Target = ent
end
local function apr(a,b,c)
	local z = math.AngleDifference( b, a )
	return math.Approach( a, a + z, c )
end
function ENT:PhysicsUpdate()
	if self.Target then
		local angdiff = (self.Target:GetPos() - self:GetPos()):Angle()

		local ang = LerpAngle(0.1,angdiff, self:GetAngles())

		self:SetAngles(self:GetAngles() + ang )
		//self:SetPos( self:GetPos() + self:GetForward() * self.speed )

	end
	if ( ValidEntity( self.Target ) ) then 
		
		local dir = ( self.Target:GetPos() - self:GetPos() ):Angle()
		local d = self:GetPos():Distance( self.Target:GetPos() )
		local a = self:GetAngles()
		a.p, a.r, a.y = apr( a.p, dir.p, 2.4 ),apr( a.r, dir.r, 4 ),apr( a.y, dir.y, 4.0 )

		self:SetAngles( a )
	
	end

	self:GetPhysicsObject():SetVelocity( self:GetForward() * self.speed )
	
end
function ENT:PhysicsCollide( data , physobj)
	MsgN("COLLIDED")
	//SafeRemoveEntity(self)
end